<template name="chooseOrgList">
	<view>
		<scroll-view scroll-y class="page">
		<cu-custom bgColor="bg-gradual-blue" :isBack="true" backRouterName="login">
			<block slot="content">组织列表</block>
		</cu-custom>
		<view>
			<view class="cu-list menu sm-border card-menu margin-top " >
				<view class="cu-item arrow animation-slide-bottom" v-for="(item,index) in orgList" @tap="chooseOrg(item)">
					<view class="content">
						<text class="cuIcon-locationfill text-blue"></text>
						<text class="text-grey">{{item.departName}}</text>
					</view>
				</view>
			</view>
		</view>
		</scroll-view>
	</view>
</template>



<script>
	import { mapActions } from "vuex"
	export default {
		data() {
			return {
				orgList:[],
				warehouseList:[],
			}
		},
		onLoad:function(option){
			if(!option.item){
				uni.navigateTo({
					url: '/pages/login/login'
				});
			}
			const tempItem = JSON.parse(decodeURIComponent(option.item));
			this.orgList = tempItem;
		},
		methods: {
			...mapActions(["orgChoose"]),
			chooseOrg(item){
				this.orgChoose(item).then((res) => {
					if(res.data.success){
						 this.warehouseList = res.data.result.warehouseInfo
						 uni.navigateTo({
							url: '/pages/wms/chooseWarehouseList?item='+ encodeURIComponent(JSON.stringify(this.warehouseList))
						 });
						}else{
						  this.$tip.err(res.data.message);
						}
					}).catch((err) => {
					  let msg = err.data.message || "请求出现错误，请稍后再试"
					  this.$tip.alert(msg);
					})
			},
		}
	}
</script>

<style>
</style>